/****************************************************************************************/
/* MediaFrame is an Open Source streaming media platform in Java                        */
/* which provides a fast, easy to implement and extremely small applet                  */
/* that enables to view your audio/video content without having                         */
/* to rely on external player applications or bulky plug-ins.                           */
/*                                                                                      */
/*--------------------------------------------------------------------------------------*/
/*                                                                                      */
/* "DataFrame.java"                                                                     */
/*                                                                                      */
/*--------------------------------------------------------------------------------------*/
/*                                                                                      */
/* We changed a lot of code and added a lot of functionality.							*/
/* This includes, but not limited to, the following changes:							*/
/* 1. The project was renamed to MediaFrame;											*/
/* 2. The connection speed detection procedure was added;								*/
/* 3. The JavaScript API functions were added;											*/
/* 4. The pre and post image support functionality was added;							*/
/* 5. The ability to save movie into the local disk was added;							*/
/* 6. The inner buffer for a movie file was added;										*/
/* 7. The click-through functionality was added;    									*/
/* 8. The .zip files support was added;    												*/
/* 9. The realtime feedback agent functionality was added.    							*/
/* For the full list of the current functionality please visit the following web page:	*/
/* http://mediaframe.org/																*/
/*    																					*/
/* 06 Jul 2002 - 19 Dec 2004 Konstantin Belous, Oleg Lebedev							*/
/*																						*/
/*--------------------------------------------------------------------------------------*/
/*                                                                                      */
/* This program is free software; you can redistribute it and/or modify it under the    */
/* terms of the GNU General Public License as published by the Free Software            */
/* Foundation; either version 2 of the License, or (at your option) any later version.  */
/*                                                                                      */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY      */
/* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      */
/* PARTICULAR PURPOSE. See the GNU General Public License for more details.             */
/*                                                                                      */
/* You should have received a copy of the GNU General Public License along with this    */
/* program; (See "LICENSE.GPL"). If not, write to the Free Software Foundation, Inc.,   */
/* 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                            */
/*                                                                                      */
/*--------------------------------------------------------------------------------------*/
/*                                                                                      */
/* If the program runs as Java applet it isn't "interactive" in the sense of the GNU    */
/* General Public License. So paragraph 2c doesn't apply.                               */
/*                                                                                      */
/****************************************************************************************/

package mediaframe.mpeg1;

/**
 * The <code>DataFrame</code> class represents one frame of video or audio data.
 * It contains the link to the first <code>DataBlock</code> with movie's data.
 */
public class DataFrame
{
	/** I video frame type. */
	public final static int I_FRAME = 1;
	/** P video frame type. */
	public final static int P_FRAME = 2;
	/** B video frame type. */
	public final static int B_FRAME = 3;
/*	public final static int TYPE_VIDEO = 10;
	public final static int PACK_START = 11;
	public final static int SLICE_START = 12;
	public final static int SYSTEM_START = 13; */
	/** Audio frame type. */
	public final static int TYPE_AUDIO = 14;
	/** SEQ_START (start of sequence) header frame type. */
	public final static int SEQ_START = 15;
	/** GOP_START (start of group of pictutes) header frame type. */
	public final static int GOP_START = 16;

	/** 0xFFFFFFFF (4 bytes) mask for the input data. */
	public static final long MASK = (255L << 24) + (255L << 16) + (255L << 8) + 255L;

	/** The type of the data frame. */
	protected int _type = -1;

	/** The first <code>DataBlock</code> in the list of frame's data blocks. */
	private DataBlock firstDataBlock = new DataBlock();

	/** The current time stamp of the frame. */
	protected long _time_stamp = -1;

	/** The file position of the frame. */
	protected int file_position;

	/** The size of this frame in bytes. */
	public int size = 0;		

	/** <tt>True</tt>, if the end of movie's file has been reached. */
	protected boolean _eof = false;
	
	/**
	 * Constructs an empty <code>DataFrame</code> with the specified time stamp and file position.
	 * @param time the time stamp of the frame.
	 * @param file_position the file position of the frame.
	 */
	public DataFrame(long time, int file_position) {
		super();
		_time_stamp = time;
		this.file_position = file_position;
	}

	/**
	 * Gets the type of the frame.
	 * @return the type of the frame.
	 */
	public int getType() {
		return _type;
	}

	/**
	 * Sets the type of the frame.
	 * @param type the type to set.
	 */
	public void setType(int type) {
		_type = type;
	}

	/**
	 * Gets the first <code>DataBlock</code> in the list of frame's data blocks.
	 * @return the first <code>DataBlock</code> in the list of frame's data blocks.
	 */
	public DataBlock getFirstDataBlock() {
		return firstDataBlock;
	}

	/**
	 * Gets the time stamp of the frame.
	 * @return the time stamp of the frame.
	 */
	public long getTimeStamp() {
		return _time_stamp;
	}

	/**
	 * Gets the file position of the frame.
	 * @return the file position of the frame.
	 */	
	public int getFilePosition() {
		return file_position;
	}

}
